# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=ruby-listen
_gemname=listen
pkgver=3.7.1
pkgrel=1
pkgdesc="Listens to file modifications and notifies you about the changes"
url="https://github.com/guard/listen"
arch="noarch"
license="MIT"
depends="ruby ruby-rb-inotify"
checkdepends="ruby-rspec"
source="https://github.com/guard/listen/archive/v$pkgver/$_gemname-$pkgver.tar.gz
	tests-remove-unnecessary-requires.patch
	gemspec.patch
	"
builddir="$srcdir/$_gemname-$pkgver"

prepare() {
	default_prepare

	# macOS-only
	rm spec/lib/listen/adapter/darwin_spec.rb

	# CLI requires gem 'thor'
	rm spec/lib/listen/cli_spec.rb
}

build() {
	gem build $_gemname.gemspec
}

check() {
	rspec .
}

package() {
	local gemdir="$pkgdir/$(ruby -e 'puts Gem.default_dir')"

	gem install \
		--local \
		--install-dir "$gemdir" \
		--ignore-dependencies \
		--no-document \
		--verbose \
		$_gemname

	# Remove unnecessary files and rubbish...
	# bin/listen requires extra dependency (thor)
	cd "$gemdir"
	rm -r bin cache build_info doc extensions
}

sha512sums="
f082e177b14f86c0906af3760f2da81b1574aee5931ef308c640c537bf0e70488b9854c7f1515545ddee76d4a203734b47a9a3d501955214562cec7acc590e1e  listen-3.7.1.tar.gz
b9e8589d6695c79060fa6122a54410bb4fc70e76cc93d745cac3ccf40b28600001cd9f39dbc47b52fe19bc9c69f15f95933d51caed263e1255c0b2097d05acd8  tests-remove-unnecessary-requires.patch
07a9d8825c7400db88a1911f39348f51c0132bbbea04c8a029dd86519f013def966c1dd25f352e5b4533e413c569782ae6dfd0ea3fb683b25fcfbf89fd50ae4a  gemspec.patch
"
